<?php

namespace app\admin\controller;

use think\Controller;
use think\Request;


/**
 * 房间规格类
 */
class Specifications extends Base
{
    public function created()
    {
        if (!input('?name') && empty(input('name'))) {
            return Result(0, '请填写规格名称');
        }
        $name = input('name');
        return model('Specifications')->Created($name);
    }

    public function del($id = 0)
    {
        if (empty($id)) {
            return Result(0, '请选择正确的数据');
        }

        return model('Specifications')->DeleteById($id);

    }

    public function read($id = 0)
    {
        if (empty($id)) {
            return Result(0, '请选择正确的数据');
        }

        return model('Specifications')->GetInfo($id);

    }

    public function list($page = 0)
    {
        $option = [];
        (input('?name') && !empty(input('name'))) ? $option['name'] = input('name') : '';
        return model('Specifications')->GetList($page, $option);
        
    }

    public function modify($id = 0)
    {
        if (empty($id)) {
            return Result(0, '请选择正确的数据');
        }

        $option = [];
        (input('?name') && !empty(input('name'))) ? $option['name'] = input('name') : '';

        if (count($option) === 0) {
            return Result(0, '请输入需要修改的数据');
        }

        return model('Specifications')->ModifyData($id, $option);
    }
}
